#include "Game.h"
#include "XMLParser.h"



using namespace std;




/**
 * Loads all Terrain information for the game.
 * @see GetConfig::GetConfig()
 * @see GetConfig::addATTROption()
 * @see GetConfig::readClassConfigFile
 * @param void
 * @return void
 */
void Game::loadTerrainInformation()
{
	XMLParser appConfig(GAME_LOADCONFIG_TERRAIN_ROOTELEM, GAME_LOADCONFIG_TERRAIN_FIRSTELEM, GAME_LOADCONFIG_TERRAIN_SECDELEM);

	appConfig.addATTROption(GAME_LOADCONFIG_TERRAIN_ATTR1);
	appConfig.addATTROption(GAME_LOADCONFIG_TERRAIN_ATTR2);
	appConfig.addATTROption(GAME_LOADCONFIG_TERRAIN_ATTR3);
	appConfig.addATTROption(GAME_LOADCONFIG_TERRAIN_ATTR4);
	appConfig.readTerrainConfigFile(GAME_LOADCONFIG_TERRAIN_FILENAME, m_terrains);
}


/**
 * Prints out information about all the Terrains in the Game
 * @param void
 * @return void
 */
void Game::showTerrainInformation()
{
	for (unsigned int i = 0; i < m_terrains.size(); ++i)
	{
		m_terrains[i]->print();
	}
}


/**
 * Deletes all terrains in the Game
 * @param void
 * @return void
 */
void Game::freeTerrainInformation()
{
	if (m_terrains.size() == 0)
	{
		cout << "No terrains information available." << endl;
	}
	else
	{
		for (unsigned int i = 0; i < m_terrains.size(); ++i)
		{
			Terrain* delTerrain;

			delTerrain = m_terrains[i];
			delete delTerrain;
		}
		m_terrains.resize(0);
	}
}